package net.zjitc.dao.impl;

import com.sun.org.apache.xpath.internal.operations.Or;

import net.zjitc.dao.OrderDao;
import net.zjitc.pojo.Order;
import net.zjitc.utils.db.C3P0Utils;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by Hisen on 2017/11/28.
 */
public class OrderDaoImpl implements OrderDao {


  @Override
  public List<Order> list() {

    //查总条数
    QueryRunner runner = new QueryRunner(C3P0Utils.getDataSource());
    String sql = "select * from orders";

    List orderList = null;
    try {
      orderList = runner.query(sql, new BeanListHandler<Order>(Order.class));
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return orderList;
  }
}
